﻿using System;
using System.IO;
using Microsoft.Xna.Framework;

namespace LevelEditor
{
    public static class Extentions
    {
        /// <summary>
        /// Reads a 3-float vector from the file, and advances the stream by 12 bytes
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>The vector from the file</returns>
        public static Vector3 ReadVector3(this BinaryReader reader)
        {
            Vector3 outval = Vector3.Zero;

            // read x, y, z data
            outval.X = reader.ReadSingle();
            outval.Y = reader.ReadSingle();
            outval.Z = reader.ReadSingle();

            return outval;
        }

        /// <summary>
        /// Reads a 2-float vector from the file and advances the file by 8 bytes
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>The vector from the file</returns>
        public static Vector2 ReadVector2(this BinaryReader reader)
        {
            Vector2 outval = Vector2.Zero;

            // read x, y data
            outval.X = reader.ReadSingle();
            outval.Y = reader.ReadSingle();

            return outval;
        }
    }
}